

export function formatTime(c, d) {
  if (isNaN(d) || isNaN(c)) { 
    return "--:--/--:--"
  }

  let s = new Array()
  for (s[0] = s[1] = ""; d > 60; d = (d % 60), c = (c % 60)) {
      s[1] += parseInt(d / 60).toString().padStart(2, '0') + ":"
      if (c > 60) {
        s[0] += parseInt(c / 60).toString().padStart(2, '0') + ":"
      } else {
        s[0] += "00:"
      }
  }
  s[1] += d.toString().padStart(2, '0')
  s[0] += c.toString().padStart(2, '0')
  return s.join(" / ")
}

export function stringTime(d) {
  let s = ""
  if (d < 60) {
    s = "00:" + d.toString().padStart(2, '0')
    return s
  }

  for (s = ""; d > 60; d = (d % 60)) {
      s += parseInt(d / 60).toString().padStart(2, '0') + ":"
  }
  s += d.toString().padStart(2, '0')
  return s
}

export function getElementPos(o) { 
  if (o == null) {
    return { 'x': 0, 'y': 0 }; 
  }

  var x = 0, y = 0; 
  do { 
    x += o.offsetLeft; 
    y += o.offsetTop; 
  } while (o = o.offsetParent); 

  return { 'x': x, 'y': y }; 
}